package b.a.c;

import org.w3c.dom.Attr;
import org.w3c.dom.Element;
import org.w3c.dom.NamedNodeMap;
import org.w3c.dom.Node;
import org.w3c.dom.svg.SVGDocument;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class b
{
  public static final RenderingHints.Key a = new b_(null);
  private static final String b = "href";
  private static final String c = "id";
  private final Pattern d = Pattern.compile("url\\(\\#(.+?)\\)");
  private int e = 0;
  public static int f;
  
  public void a(SVGDocument paramSVGDocument)
  {
    this.e += 1;
    a(paramSVGDocument.getDocumentElement());
  }
  
  private void a(Element paramElement)
  {
    int k = f;
    if (k == 0) {
      if (paramElement.hasAttribute("id"))
      {
        localObject1 = paramElement.getAttribute("id");
        String str = "svg" + this.e + '.' + (String)localObject1;
        paramElement.setAttribute("id", str);
      }
    }
    Object localObject1 = paramElement.getAttributes();
    int i = 0;
    int j = ((NamedNodeMap)localObject1).getLength();
    do
    {
      if (i >= j) {
        break;
      }
      Attr localAttr = (Attr)((NamedNodeMap)localObject1).item(i);
      if (k == 0)
      {
        if (k != 0) {
          break label322;
        }
        if (localAttr.getSpecified())
        {
          Object localObject2;
          if ((k != 0) || (("href".equals(localAttr.getLocalName())) && ((k != 0) || ("http://www.w3.org/1999/xlink".equals(localAttr.getNamespaceURI())))))
          {
            localObject2 = localAttr.getValue();
            if (k != 0) {
              continue;
            }
            if ((((String)localObject2).length() > 1) && ('#' == ((String)localObject2).charAt(0)))
            {
              localAttr.setValue("#svg" + this.e + '.' + ((String)localObject2).substring(1));
              if (k == 0) {}
            }
          }
          else
          {
            localObject2 = this.d.matcher(localAttr.getValue());
            localAttr.setValue(((Matcher)localObject2).replaceAll("url(#svg" + this.e + ".$1)"));
          }
        }
        i++;
      }
    } while (k == 0);
    if ((k != 0) || (paramElement.hasChildNodes()))
    {
      label322:
      Node localNode = paramElement.getFirstChild();
      do
      {
        if (localNode == null) {
          break;
        }
        if (k == 0) {
          if (localNode.getNodeType() == 1) {
            a((Element)localNode);
          }
        }
        localNode = localNode.getNextSibling();
      } while (k == 0);
    }
  }
  
  private static final class b_
    extends RenderingHints.Key
  {
    private b_()
    {
      super();
    }
    
    public boolean isCompatibleValue(Object paramObject)
    {
      int i = b.f;
      if ((i != 0) || (paramObject != null)) {
        if (i != 0) {
          break label24;
        }
      }
      label24:
      return (paramObject instanceof b);
    }
    
    b_(b.0 param0)
    {
      this();
    }
  }
}



/* Location:           E:\idea\

 * Qualified Name:     b.a.c.b

 * JD-Core Version:    0.7.0.1

 */